<p class="tips">     
    <span id="_tips">{$addons_data.tips}</span>
</p>
<div class="img_upload_wrp" id="js_{$addons_data.name}_upload_wrp">    
    {present name="addons_data.picList"}
    {volist name="addons_data.picList" id="li"}
    <div class="img_upload_box img_upload_preview_box js_edit_pic_wrp">
        <img class="preview_photo" src="{$li}" />      
        <p class="img_upload_edit_area js_edit_area"><a href="javascript:;"  title="删除" class="icon wb-trash js_delete"></a></p>
    </div>
    {/volist}
    {/present}
    <div style="margin-bottom:5px" class="img_upload_box js_img_upload_box">
        <a class="img_upload_box_oper" id="js_{$addons_data.name}_pic" href="javascript:;">
            {if condition="($addons_data['type'] eq 'add')"}            
            <i class="icon wb-plus js_add_gray">上传</i>
            <img class="preview_photo" style="display:none" /> 
            {/if}
        </a>        
    </div>    
</div>


<script type="text/javascript">
    var checktype_{$addons_data.name} = "{$addons_data['checktype']}";
    var folder_{$addons_data.name} = "{$addons_data['folder']}";
    var __resources_callback_{$addons_data.name} = "{$addons_data.callback}";
    $("#js_{$addons_data.name}_pic").click(function () {
        if (typeof is_view_page != 'undefined' && is_view_page)
            return;
        var _this = $(this);
        var url = getURL("pic/index", "folder=" + folder_{$addons_data.name} +"&checktype=" + checktype_{$addons_data.name}, "resources");
        parent._upload_tips = '{$addons_data.tips}';
        _openResourcesPic(url, function (paths) {
            //回调
            var arr = paths.split(",");
            var path = arr[0];
            if (path != "") {
                if (checktype_{$addons_data.name} == "" || checktype_{$addons_data.name} == "1") {
                    _this.find(".js_add_gray").hide();
                    $("#{$addons_data.name}").val(paths);
                    _this.find(".preview_photo").attr("src", arr[0]).show();
                }
                if (__resources_callback_{$addons_data.name} && __resources_callback_{$addons_data.name} != "")
                    eval(__resources_callback_{$addons_data.name}).call(_this, paths);
            }
        });
    });
    function _openResourcesPic(url, callback) {
        parent.layer.open({
            type: 2,
            title: '图片素材',
            btn: ['确定', '取消'],
            area: ['800px', '600px'],
            maxmin: false,
            //skin: 'layui-layer-rim', //加上边框
            content: url,
            yes: function (index) {
                if (callback) {
                    var d = window.parent.frames["layui-layer-iframe" + index];
                    callback(d.ok());
                }
                parent.layer.close(index); //一般设定yes回调，必须进行手工关闭
            }
        });
    }
    function setPicValue(name, val) {
        if (val != "")
            $("#js_" + name + "_pic").html('<img class="preview_photo" src="' + val + '" />');
    }
    function appendPic(name, path) {
        var html = '<div class="img_upload_box img_upload_preview_box js_edit_pic_wrp">';
        html += '<img class="preview_photo" src="' + path + '" /><p class="img_upload_edit_area js_edit_area"><a href="javascript:;" title="删除" class="icon wb-trash js_delete"></a></p></div>';
        $("#js_" + name + "_upload_wrp").find(".js_img_upload_box").before(html);
    }
    function clearPic(name) {
        $("#js_" + name + "_upload_wrp").find(".js_edit_pic_wrp").remove();
    }
</script>